package com.showworkflow.controller;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.showworkflow.entity.FileHistory;
import com.showworkflow.service.DifyService;
import com.showworkflow.service.FileStorageService;
import com.showworkflow.service.WordConversionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/api/files")
@CrossOrigin(origins = {"http://localhost:5173", "http://localhost:5174", "http://localhost:5175"})
public class FileController {

    private final FileStorageService fileStorageService;
    private final WordConversionService wordConversionService;
    private final DifyService difyService;

    @Autowired
    public FileController(FileStorageService fileStorageService,
                         WordConversionService wordConversionService,
                         DifyService difyService) {
        this.fileStorageService = fileStorageService;
        this.wordConversionService = wordConversionService;
        this.difyService = difyService;
    }

    // @PostMapping(value = "/process-word", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    // public ResponseEntity<?> processWordFiles(
    //         @RequestParam("files") MultipartFile[] files,
    //         @RequestParam("sessionId") String sessionId) {
        
    //     try {
    //         if (files.length != 2) {
    //             return ResponseEntity.badRequest().body("请上传2个Word文档");
    //         }

    //         for (MultipartFile file : files) {
    //             if (!file.getOriginalFilename().endsWith(".docx")) {
    //                 return ResponseEntity.badRequest().body("只支持Word文档格式(.docx)");
    //             }
    //         }

    //         // 直接调用dify服务处理文件
    //         String result1 = difyService.uploadAndGetJson(files[0]);
    //         String result2 = difyService.uploadAndGetJson(files[1]);
            
    //         // 返回dify服务的处理结果
    //         return ResponseEntity.ok(Map.of(
    //             "result1", result1,
    //             "result2", result2
    //         ));

    //     } catch (IOException e) {
    //         return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
    //                 .body("文件处理失败: " + e.getMessage());
    //     }
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ResponseEntity<?> uploadFiles(
            @RequestParam("files") MultipartFile[] files,
            @RequestParam("sessionId") String sessionId) {
        
        if (files == null || files.length != 2) {
            return ResponseEntity.badRequest().body("请上传监督检查记录和整改通知书两个文件");
        }
        
        log.info("文件上传请求 - sessionId: {}, 文件1: {}, 文件2: {}", 
            sessionId, files[0].getOriginalFilename(), files[1].getOriginalFilename());
        
        try {
            // 验证文件格式
            for (MultipartFile file : files) {
                String filename = file.getOriginalFilename();
                if (filename == null || (!filename.endsWith(".docx") && !filename.endsWith(".doc"))) {
                    return ResponseEntity.badRequest().body("只支持Word文档格式(.doc/.docx)");
                }
            }

            // 1. 发送到Dify处理
            String difyResponse = difyService.processFilesToDify(files[0], files[1]);
            log.info("Dify处理结果: {}", difyResponse);

            // 2. 提取实际的JSON数据
            String actualJsonData = extractJsonDataFromDifyResponse(difyResponse);
            log.info("提取的JSON数据: {}", actualJsonData);

            // 3. 存储原始文件
            Map<String, Object> storageResult = fileStorageService.storeFiles(files, sessionId);

            // 4. 填充Word模板
            String templateName = "行政处罚立案审批表模版.docx";
            log.info("开始填充Word模板，模板名称: {}", templateName);
            Map<String, String> conversionResult;
            try {
                conversionResult = wordConversionService.fillCaseForm(actualJsonData, templateName);
                log.info("Word模板填充成功，输出路径: {}", conversionResult.get("wordPath"));
                if (conversionResult.get("htmlPath") != null) {
                    log.info("HTML转换成功，输出路径: {}", conversionResult.get("htmlPath"));
                }
            } catch (Exception e) {
                log.error("Word模板填充失败: {}", e.getMessage(), e);
                throw new IOException("Word模板填充失败: " + e.getMessage(), e);
            }
            
            // 返回结果
            Map<String, Object> result = new HashMap<>();
            result.put("success", true);
            result.put("originalFiles", storageResult.get("originalFiles"));
            result.put("outputPath", conversionResult.get("wordPath"));
            result.put("htmlPath", conversionResult.get("htmlPath"));
            result.put("jsonData", actualJsonData);
            
            return ResponseEntity.ok(result);

        } catch (IOException e) {
            log.error("文件处理失败 - sessionId: {}, 错误: {}", sessionId, e.getMessage(), e);
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                    .body("文件处理失败: " + e.getMessage());
        }
    }

    @PostMapping(value = "/generate-interrogation", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<?> generateInterrogationRecord(@RequestBody Map<String, Object> request) {

        String sessionId = (String) request.get("sessionId");
        String caseApprovalContent = (String) request.get("caseApprovalContent");

        if (sessionId == null || caseApprovalContent == null) {
            return ResponseEntity.badRequest().body("请提供sessionId和caseApprovalContent");
        }

        log.info("笔录生成请求 - sessionId: {}, 立案审批表内容长度: {}", sessionId, caseApprovalContent.length());

        try {
            // 1. 发送立案审批表内容到Dify处理，生成笔录HTML
            String difyResponse = difyService.generateInterrogationRecord(caseApprovalContent);
            log.info("笔录Dify处理结果: {}", difyResponse);

            // 2. 提取HTML内容
            String htmlContent = extractHtmlDataFromDifyResponse(difyResponse);
            log.info("提取的HTML内容长度: {}", htmlContent.length());

            // 3. 保存HTML内容到文件
            String timestamp = String.valueOf(System.currentTimeMillis());
            String htmlFileName = "interrogation_record_" + timestamp + ".html";
            String htmlFilePath = saveHtmlToFile(htmlContent, htmlFileName);
            log.info("HTML文件保存成功，路径: {}", htmlFilePath);

            // 4. 使用Python脚本将HTML转换为Word
            String wordFileName = "interrogation_record_" + timestamp + ".docx";
            String wordFilePath = convertHtmlToWord(htmlFilePath, wordFileName);
            log.info("Word文件生成成功，路径: {}", wordFilePath);

            // 返回结果
            Map<String, Object> result = new HashMap<>();
            result.put("success", true);
            result.put("htmlPath", htmlFilePath);
            result.put("wordPath", wordFilePath);
            result.put("htmlContent", htmlContent);

            return ResponseEntity.ok(result);

        } catch (IOException e) {
            log.error("笔录生成失败 - sessionId: {}, 错误: {}", sessionId, e.getMessage(), e);
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                    .body("笔录生成失败: " + e.getMessage());
        }
    }

    @GetMapping("/history/{sessionId}")
    public ResponseEntity<List<FileHistory>> getFileHistories(@PathVariable String sessionId) {
        List<FileHistory> histories = fileStorageService.getFileHistories(sessionId);
        return ResponseEntity.ok(histories);
    }

    @GetMapping("/history/{sessionId}/{fileId}")
    public ResponseEntity<?> getFileHistory(@PathVariable String sessionId, @PathVariable String fileId) {
        FileHistory history = fileStorageService.getFileHistory(sessionId, fileId);
        if (history == null) {
            return ResponseEntity.notFound().build();
        }
        return ResponseEntity.ok(history);
    }

    /**
     * 下载生成的Word文档
     */
    @GetMapping("/download/generated/{filename}")
    public ResponseEntity<byte[]> downloadGeneratedFile(@PathVariable String filename) {
        log.info("下载生成文件请求: {}", filename);
        try {
            // 构造文件路径
            String rootPath = System.getProperty("user.dir");
            Path filePath;

            if (rootPath.endsWith("backend")) {
                filePath = Paths.get("src/main/resources/generated/" + filename);
            } else {
                filePath = Paths.get("backend/src/main/resources/generated/" + filename);
            }

            log.info("尝试下载文件: {}", filePath);

            if (!Files.exists(filePath)) {
                log.warn("文件不存在: {}", filePath);
                return ResponseEntity.notFound().build();
            }

            byte[] content = Files.readAllBytes(filePath);

            HttpHeaders headers = new HttpHeaders();

            // 根据文件扩展名设置正确的Content-Type
            if (filename.endsWith(".docx")) {
                headers.setContentType(MediaType.valueOf("application/vnd.openxmlformats-officedocument.wordprocessingml.document"));
            } else if (filename.endsWith(".doc")) {
                headers.setContentType(MediaType.valueOf("application/msword"));
            } else if (filename.endsWith(".html")) {
                headers.setContentType(MediaType.TEXT_HTML);
            } else {
                headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
            }

            headers.setContentDispositionFormData("attachment", filename);

            log.info("文件下载成功: {}, 大小: {} bytes", filename, content.length);
            return new ResponseEntity<>(content, headers, HttpStatus.OK);

        } catch (IOException e) {
            log.error("下载生成文件失败: {}, 错误: {}", filename, e.getMessage(), e);
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
        }
    }

    @GetMapping("/download/{sessionId}/{fileId}")
    public ResponseEntity<byte[]> downloadFile(@PathVariable String sessionId, @PathVariable String fileId) {
        log.info("文件下载请求 - sessionId: {}, fileId: {}", sessionId, fileId);
        try {
            FileHistory history = fileStorageService.getFileHistory(sessionId, fileId);
            if (history == null) {
                return ResponseEntity.notFound().build();
            }

            byte[] content = fileStorageService.getFileContent(history.getStoredFilePath());
            
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
            headers.setContentDispositionFormData("attachment", history.getOriginalFileName());

            log.info("文件下载成功 - sessionId: {}, fileId: {}, 文件名: {}", 
                sessionId, fileId, history.getOriginalFileName());
            return new ResponseEntity<>(content, headers, HttpStatus.OK);

        } catch (IOException e) {
            log.error("文件下载失败 - sessionId: {}, fileId: {}, 错误: {}", 
                sessionId, fileId, e.getMessage(), e);
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
        }
    }

    @PostMapping("/fill-case-form")
    public ResponseEntity<String> fillCaseForm(
            @RequestParam("jsonData") String jsonData,
            @RequestParam("templateName") String templateName) {
        
        try {
            String templatePath = "templates/" + templateName;
            String outputPath = "generated/" + templateName.replace("（模板）", "") + "_" + System.currentTimeMillis() + ".docx";
            
            wordConversionService.fillCaseApprovalForm(jsonData, templatePath, outputPath);
            
            return ResponseEntity.ok("立案审批表生成成功: " + outputPath);
        } catch (IOException e) {
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                    .body("立案审批表生成失败: " + e.getMessage());
        }
    }


    @GetMapping("/download-word/{sessionId}/{fileId}")
    public ResponseEntity<byte[]> downloadWord(@PathVariable String sessionId, @PathVariable String fileId) {
        try {
            FileHistory history = fileStorageService.getFileHistory(sessionId, fileId);
            if (history == null) {
                return ResponseEntity.notFound().build();
            }

            byte[] content = fileStorageService.getFileContent(history.getWordFilePath());
            
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
            headers.setContentDispositionFormData("attachment", history.getOriginalFileName());

            return new ResponseEntity<>(content, headers, HttpStatus.OK);

        } catch (IOException e) {
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
        }
    }

    /**
     * 从Dify响应中提取JSON数据
     */
    private String extractJsonDataFromDifyResponse(String difyResponse) {
        try {
            ObjectMapper mapper = new ObjectMapper();
            JsonNode rootNode = mapper.readTree(difyResponse);

            // 从data.outputs.text中提取JSON数据
            JsonNode dataNode = rootNode.get("data");
            if (dataNode != null) {
                JsonNode outputsNode = dataNode.get("outputs");
                if (outputsNode != null) {
                    JsonNode textNode = outputsNode.get("text");
                    if (textNode != null) {
                        return textNode.asText();
                    }
                }
            }

            // 如果没有找到嵌套结构，检查是否直接返回了JSON字符串
            String trimmedResponse = difyResponse.trim();
            if (trimmedResponse.startsWith("{") && trimmedResponse.endsWith("}")) {
                return difyResponse;
            }

            log.warn("无法从Dify响应中提取JSON数据，使用原始响应");
            return difyResponse;

        } catch (Exception e) {
            log.error("提取JSON数据失败: {}", e.getMessage(), e);
            return difyResponse;
        }
    }

    /**
     * 从Dify响应中提取HTML数据
     */
    private String extractHtmlDataFromDifyResponse(String difyResponse) {
        try {
            ObjectMapper mapper = new ObjectMapper();
            JsonNode rootNode = mapper.readTree(difyResponse);

            // 根据笔录工作流返回的是string，直接从data.outputs.text中提取HTML
            JsonNode dataNode = rootNode.get("data");
            if (dataNode != null) {
                JsonNode outputsNode = dataNode.get("outputs");
                if (outputsNode != null) {
                    JsonNode textNode = outputsNode.get("text");
                    if (textNode != null) {
                        return textNode.asText();
                    }
                }
            }

            // 如果没有找到嵌套结构，检查是否直接返回了HTML字符串
            if (difyResponse.trim().startsWith("<") && difyResponse.trim().endsWith(">")) {
                return difyResponse;
            }

            log.warn("无法从Dify响应中提取HTML数据，使用原始响应");
            return difyResponse;

        } catch (Exception e) {
            log.error("提取HTML数据失败: {}", e.getMessage(), e);
            return difyResponse;
        }
    }

    /**
     * 保存HTML内容到文件
     */
    private String saveHtmlToFile(String htmlContent, String fileName) throws IOException {
        String rootPath = System.getProperty("user.dir");
        Path generatePath;

        if (rootPath.endsWith("backend")) {
            generatePath = Paths.get("src/main/resources/generated/");
        } else {
            generatePath = Paths.get("backend/src/main/resources/generated/");
        }

        // 确保目录存在
        Files.createDirectories(generatePath);

        Path htmlFilePath = generatePath.resolve(fileName);
        Files.write(htmlFilePath, htmlContent.getBytes(StandardCharsets.UTF_8));

        return htmlFilePath.toString();
    }

    /**
     * 使用Python脚本将HTML转换为Word
     */
    private String convertHtmlToWord(String htmlFilePath, String wordFileName) throws IOException {
        try {
            String rootPath = System.getProperty("user.dir");
            log.info("当前工作目录: {}", rootPath);

            // 使用绝对路径避免相对路径问题
            Path projectRoot;
            if (rootPath.endsWith("backend")) {
                projectRoot = Paths.get(rootPath);
            } else {
                projectRoot = Paths.get(rootPath, "backend");
            }

            Path generatePath = projectRoot.resolve("src/main/resources/generated/");
            Path pythonScriptPath = projectRoot.resolve("src/main/resources/fire/html2word.py");

            log.info("Python脚本路径: {}", pythonScriptPath.toAbsolutePath());
            log.info("生成目录路径: {}", generatePath.toAbsolutePath());

            // 确保目录存在
            Files.createDirectories(generatePath);

            // 检查Python脚本是否存在
            if (!Files.exists(pythonScriptPath)) {
                throw new IOException("Python脚本不存在: " + pythonScriptPath.toAbsolutePath());
            }

            Path wordFilePath = generatePath.resolve(wordFileName);

            // 构建Python命令 - 使用绝对路径
            ProcessBuilder processBuilder = new ProcessBuilder(
                "python", pythonScriptPath.toAbsolutePath().toString(),
                Paths.get(htmlFilePath).toAbsolutePath().toString(),
                wordFilePath.toAbsolutePath().toString()
            );

            // 设置工作目录为项目根目录
            processBuilder.directory(projectRoot.toFile());

            log.info("执行Python命令: python {} {} {}", pythonScriptPath.toAbsolutePath(), htmlFilePath, wordFilePath.toAbsolutePath());

            Process process = processBuilder.start();

            // 等待进程完成
            int exitCode = process.waitFor();

            if (exitCode != 0) {
                // 读取错误输出
                StringBuilder errorOutput = new StringBuilder();
                try (java.io.BufferedReader reader = new java.io.BufferedReader(
                        new java.io.InputStreamReader(process.getErrorStream()))) {
                    String line;
                    while ((line = reader.readLine()) != null) {
                        errorOutput.append(line).append("\n");
                    }
                }
                throw new IOException("Python脚本执行失败，退出码: " + exitCode + "，错误信息: " + errorOutput.toString());
            }

            // 检查Word文件是否生成成功
            if (!Files.exists(wordFilePath)) {
                throw new IOException("Word文件生成失败，文件不存在: " + wordFilePath);
            }

            return wordFilePath.toString();

        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new IOException("Python脚本执行被中断", e);
        }
    }

    /**
     * 获取HTML文件内容用于预览
     */
    @GetMapping("/html/{filename}")
    public ResponseEntity<String> getHtmlContent(@PathVariable String filename) {
        log.info("HTML文件请求: {}", filename);
        try {
            // 构造HTML文件路径
            String rootPath = System.getProperty("user.dir");
            Path htmlPath;

            if (rootPath.endsWith("backend")) {
                htmlPath = Paths.get("src/main/resources/generated/" + filename);
            } else {
                htmlPath = Paths.get("backend/src/main/resources/generated/" + filename);
            }

            log.info("尝试读取HTML文件: {}", htmlPath);

            if (!Files.exists(htmlPath)) {
                log.warn("HTML文件不存在: {}，尝试从Word文件生成HTML", htmlPath);

                // 尝试找到对应的Word文件并转换
                String wordFilename = filename.replace(".html", ".docx");
                Path wordPath;
                if (rootPath.endsWith("backend")) {
                    wordPath = Paths.get("src/main/resources/generated/" + wordFilename);
                } else {
                    wordPath = Paths.get("backend/src/main/resources/generated/" + wordFilename);
                }

                if (Files.exists(wordPath)) {
                    log.info("找到Word文件: {}，生成替代HTML预览", wordPath);
                    // 生成一个简单的HTML预览
                    String htmlContent = generateSimpleHtmlFromWordPath(wordPath.toString(), filename);
                    return ResponseEntity.ok()
                            .contentType(MediaType.TEXT_HTML)
                            .header(HttpHeaders.CACHE_CONTROL, "no-cache")
                            .body(htmlContent);
                } else {
                    log.warn("对应的Word文件也不存在: {}", wordPath);
                    return ResponseEntity.notFound().build();
                }
            }

            // 读取HTML文件内容
            String htmlContent = Files.readString(htmlPath, StandardCharsets.UTF_8);
            log.info("HTML文件读取成功，内容长度: {}", htmlContent.length());

            return ResponseEntity.ok()
                    .contentType(MediaType.TEXT_HTML)
                    .header(HttpHeaders.CACHE_CONTROL, "no-cache")
                    .body(htmlContent);

        } catch (IOException e) {
            log.error("读取HTML文件失败: {}", e.getMessage(), e);
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                    .body("读取HTML文件失败: " + e.getMessage());
        }
    }

    /**
     * 当HTML文件不存在时，生成简单的HTML预览
     */
    private String generateSimpleHtmlFromWordPath(String wordPath, String htmlFilename) {
        try {
            String currentTime = new java.text.SimpleDateFormat("yyyy年MM月dd日 HH:mm").format(new java.util.Date());

            return "<!DOCTYPE html>\n" +
                   "<html lang=\"zh-CN\">\n" +
                   "<head>\n" +
                   "    <meta charset=\"UTF-8\">\n" +
                   "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" +
                   "    <title>立案审批表预览</title>\n" +
                   "    <style>\n" +
                   "        body { font-family: '宋体', '微软雅黑', Arial, sans-serif; margin: 40px; background-color: #f5f5f5; }\n" +
                   "        .container { max-width: 800px; margin: 0 auto; background-color: white; padding: 30px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); border-radius: 8px; }\n" +
                   "        .header { text-align: center; margin-bottom: 30px; }\n" +
                   "        .title { font-size: 20px; font-weight: bold; margin-bottom: 20px; color: #333; }\n" +
                   "        .notice { padding: 20px; background-color: #e6f7ff; border-left: 4px solid #1890ff; margin: 20px 0; border-radius: 4px; }\n" +
                   "        .download-info { padding: 15px; background-color: #f6ffed; border: 1px solid #b7eb8f; border-radius: 4px; margin-top: 20px; }\n" +
                   "        .status { padding: 10px; background-color: #fff7e6; border: 1px solid #ffd591; border-radius: 4px; margin: 10px 0; }\n" +
                   "        ul li { margin: 8px 0; }\n" +
                   "        .refresh-btn { display: inline-block; padding: 8px 16px; background-color: #52c41a; color: white; text-decoration: none; border-radius: 4px; margin-left: 10px; }\n" +
                   "        .refresh-btn:hover { background-color: #73d13d; }\n" +
                   "    </style>\n" +
                   "</head>\n" +
                   "<body>\n" +
                   "    <div class=\"container\">\n" +
                   "        <div class=\"header\">\n" +
                   "            <div class=\"title\">行政处罚立案审批表</div>\n" +
                   "            <p>文档生成时间：" + currentTime + "</p>\n" +
                   "        </div>\n" +
                   "        \n" +
                   "        <div class=\"status\">\n" +
                   "            <strong>⚠️ HTML预览状态：</strong>\n" +
                   "            由于Pandoc转换失败，暂时无法生成完整的HTML预览。\n" +
                   "            <a href=\"javascript:location.reload()\" class=\"refresh-btn\">🔄 刷新页面</a>\n" +
                   "        </div>\n" +
                   "        \n" +
                   "        <div class=\"notice\">\n" +
                   "            <h3>📋 文档信息</h3>\n" +
                   "            <p><strong>✅ Word文档已成功生成</strong>并填充了所有必要信息。</p>\n" +
                   "            \n" +
                   "            <h4>📄 文档包含内容：</h4>\n" +
                   "            <ul>\n" +
                   "                <li><strong>案件基本信息</strong> - 案件编号、案件来源、立案原因</li>\n" +
                   "                <li><strong>违法当事人信息</strong> - 个人或单位的详细信息</li>\n" +
                   "                <li><strong>违法行为详细描述</strong> - 案件简要情况和违法事实</li>\n" +
                   "                <li><strong>法律依据和条款分析</strong> - 适用的法律法规条款</li>\n" +
                   "                <li><strong>处理建议和审批意见</strong> - 执法人员的处理建议</li>\n" +
                   "                <li><strong>审批流程信息</strong> - 执法人员、经办人、审批领导签字栏</li>\n" +
                   "            </ul>\n" +
                   "        </div>\n" +
                   "        \n" +
                   "        <div class=\"download-info\">\n" +
                   "            <strong>💡 查看完整内容：</strong>\n" +
                   "            请点击左侧菜单中的\"立案审批表\"链接，通过浏览器下载完整的Word文档查看所有填充的内容和格式。\n" +
                   "        </div>\n" +
                   "    </div>\n" +
                   "</body>\n" +
                   "</html>";

        } catch (Exception e) {
            log.error("生成简单HTML预览失败: {}", e.getMessage(), e);
            return "<html><body><h3>预览生成失败</h3><p>请下载Word文档查看内容。</p></body></html>";
        }
    }
}